//
// Delaunay Triangulation
//
// Homework of CG lesson (Fall 2009) in Tsinghua University.
// All rights reserved.
//

// temp include, delete later if necessary
#include "stdafx.h"

#include "point2d.h"

// User headers
#include "base.h"

Point2d::Point2d(void)
    : x(0), y(0),z(0)
{
}

Point2d::Point2d(double tx, double ty)
    : x(tx), y(ty)
{
}

Point2d::Point2d(const Point2d& p)
{
	x = p.x;
	y = p.y;
	z = p.z;
}

Point2d Point2d::operator+(const Vector2d& v) const
{
    return Point2d(x + v.x, y + v.y);
}

Vector2d Point2d::operator-(const Point2d& p) const
{
    return Vector2d(x - p.x, y - p.y);
}

bool Point2d::operator==(const Point2d& p) const
{
    if (fabs(x - p.x) >= TOLERANCE || fabs(y - p.y) >= TOLERANCE)
        return false;

    return true;
}

bool Point2d::operator<(const Point2d& p) const
{
	if(x < p.x)
	{
	    return true;
	}
	else
	{
	    if(x > p.x)
		    return false;
		else
		    return (y < p.y);
	}
}
